<template>
	<div>
		<navigation-bar>
			<div class="searchContent">
				<el-input
					v-model="name"
					placeholder="请输入名称"
					size="mini"
					style="width: 150px; margin-right: 10px"
				></el-input>
				<custom-button
					type="search"
					style="margin-right: 10px"
					@searchClick="searchClick"
				></custom-button>
				<custom-button
					type="reset"
					style="margin-right: 10px"
					@resetClick="resetClick"
				></custom-button>
				<custom-button
					type="add"
					title="筛选判断"
					style="margin-right: 10px"
					@addClick="addClick"
				></custom-button>
			</div>
		</navigation-bar>
		<table-index
			:dataSource="dataSource"
			:tableColumns="tableColumns"
			:btnList="btnList"
			btnListWidth="60px"
			:pageSize="pageSize"
			:pageCount="pageCount"
			:pageNo="pageNo"
			@pageChange="pageChange"
			@viewRow="viewRow"
			selection
			@handleSelectionChange="handleSelectionChange"
		></table-index>

		<div v-if="dialogShow">
			<custom-dialog
				:title="dialogTitle"
				size="large"
				@dialogClose="dialogClose"
			>
				<form-index :formConfig="formConfig" :showTepe="showTepe" :type="type" ref="form">
					<!--  <div>这里还可以插入其它内容进行拓展</div> -->
				</form-index>
			</custom-dialog>
		</div>
		<div v-if="screeningJShow">
			<custom-dialog
				:title="dialogTitle"
				size="max"
				@dialogClose="screeningJClose"
			>
				<div>
					<screening-judge
						@screeningJudgeClose="screeningJClose"
						:userInfo="examineeCodeList[0]"
						type="in"
						:isFirst="true"
						:oprType="oprType"
					></screening-judge>
				</div>
			</custom-dialog>
		</div>
	</div>
</template>

<script>
	import { checkInScreeningJudgmentForm } from "@/assets/form/managementCenter/subjectManagement/firstCheckInManagement/checkInScreeningJudgmentForm"
	import customDialog from "@/components/customComponents/customDialog"
	import tableIndex from "@/components/customComponents/customeTable/tableIndex"
	import customButton from "@/components/customComponents/customForm/customButton"
	import formIndex from "@/components/customComponents/customForm/formIndex"
	import screeningJudge from "@/components/customComponents/managementCenter/commonJudge/screeningJudge"
	import navigationBar from "@/components/customComponents/managementCenter/navigationBar"
	import { AjaxCommon } from "@/libs/apiCommon"
	import { PopupCommon } from "@/libs/popupCommon"
	import { SessionCommon } from "@/libs/sessionCommon"
	export default {
		components: {
			navigationBar,
			customButton,
			tableIndex,
			customDialog,
			formIndex,
			screeningJudge,
		},
		data() {
			return {
				oprType: "add",
				screeningJShow: false,
				examineeCodeList: [],
				name: "",
				// table 相关参数  begin
				dataSource: [],
				tableColumns: [
					{
						prop: "filterNo",
						label: "筛选号",
            width: 120,
					},
					{
						prop: "randomNo",
						label: "随机号",
            width: 120,
					},
					{
						prop: "groupSeq",
						width: 120,
						label: "入组顺序号",
					},
					{
						prop: "examineeName",
						label: "姓名",
            width: 120,
					},
					{
						prop: "sex",
						label: "性别",
						dictName: "sex",
            width: 100,
					},
					{
						prop: "judgeTime",
						label: "判断时间",
						width: 200,
					},
					{
						prop: "standardJudgeByName",
						label: "判断人",
            width: 120,
					},
					{
						prop: "isPass",
						label: "是否合格",
						width: 120,
						dictName: "yn",
					},
					{
						prop: "noPassReason",
						label: "不合格入选原因",
					},
				],
				btnList: ["view"],
				pageSize: 20,
				pageCount: 100,
				pageNo: 1,
				// table 相关参数  end

				// 弹窗是否显示
				dialogShow: false,
				// 弹窗标题 (新增修改不同)
				dialogTitle: "",

				// form的配置信息
				formConfig: checkInScreeningJudgmentForm,
				showTepe:"Show",
				type: "add",
			}
		},

		methods: {
			// 左侧选中事件
			handleSelectionChange(d) {
				this.examineeCodeList = d
			},
			dialogClose() {
				this.dialogShow = false
			},
			screeningJClose() {
				this.resetClick()
				this.searchClick()
				this.examineeCodeList = []
				this.screeningJShow = false
			},
			searchClick() {
				this.pageNo = 1
				this.initPage()
			},
			resetClick() {
				this.name = ""
			},
			addClick() {
				if (this.examineeCodeList.length != 1) {
					PopupCommon.notify("info", "请选择一个受试者！")
					return
				}
				this.showTepe="Show",
				this.oprType = "add"
				this.screeningJShow = true
				this.dialogTitle =
					"新增" + JSON.parse(SessionCommon.getCurrentMenuInfo()).title
			},
			// 分页点击事件
			pageChange(p) {
				this.pageNo = p
				this.initPage()
			},
			viewRow(d) {
				this.type = "look"
				this.oprType = "view"
				this.examineeCodeList = [d.data]
				this.screeningJShow = true
				this.dialogTitle =
					"查看" + JSON.parse(SessionCommon.getCurrentMenuInfo()).title
			},
			// 初始化事件
			initPage() {
				let self = this
				AjaxCommon(
					"/ccdc/pm/em/in/emInJudge/listByPage",
					"post",
					{
						examineeName: this.name,
						pageNo: this.pageNo,
						pageSize: this.pageSize,
					},
					true
				).then((res) => {
					if (res.data.code == 200) {
						self.dataSource = res.data.result.records
						self.pageCount = res.data.result.total
					} else {
						PopupCommon.notify("error", res.data.message)
					}
				})
			},
		},
		mounted() {
			this.initPage()
		},
	}
</script>

<style></style>
